package cn.huijielong.modules.oss.entity;

import cn.huijielong.common.exception.VSException;


public final class BucketType {
	
	public final static String ALI_IMAGES_PRIVATE="images-protected";
	public final static String ALI_IMAGES_OPEN="images-open";
	public final static String ALI_ARCHIVES_PRIVATE="archives-protected";
	public final static String ALI_ARCHIVES_OPEN="archives-open";
	
	public final static String QINIU_IMAGES_PRIVATE="images";
	public final static String QINIU_IMAGES_OPEN="images-open";
	public final static String QINIU_ARCHIVES_PRIVATE="archives";
	public final static String QINIU_ARCHIVES_OPEN="archives-open";
	public final static String QINIU_QRTUANT="qrtuan";
	public final static String QINIU_VSTARTEST="vstartest";
	
	public final static int BUCKET_IMAGES_PRIVATE=1;
	public final static int BUCKET_IMAGES_OPEN=2;
	public final static int BUCKET_ARCHIVES_PRIVATE=3;
	public final static int BUCKET_ARCHIVES_OPEN=4;
	
	public final static int BUCKET_QRTUAN=5;
	public final static int BUCKET_VSTARTEST=6;
	
	public final static int OSS_TYPE_ALI=1;
	public final static int OSS_TYPE_QINIU=2;
	public final static int OSS_TYPE_QC=3;//腾讯
	
	public final static String OSS_NAME_ALI="ali";
	public final static String OSS_NAME_QINIU="qiniu";
	public final static String OSS_NAME_QC="qc";//腾讯
	
	public static String convert(String ossName,int bucketType) {
		if(OSS_NAME_ALI.equals(ossName)) {
			switch(bucketType) {
			case BUCKET_IMAGES_PRIVATE:
				return ALI_IMAGES_PRIVATE;
			case BUCKET_IMAGES_OPEN:
				return ALI_IMAGES_OPEN;
			case BUCKET_ARCHIVES_PRIVATE:
				return ALI_ARCHIVES_PRIVATE;
			case BUCKET_ARCHIVES_OPEN:
				return ALI_ARCHIVES_OPEN;
			default:
				throw new VSException("空间类型（"+bucketType+"）不能识别");
			}
		}else if(OSS_NAME_QINIU.equals(ossName)) {
			switch(bucketType) {
			case BUCKET_IMAGES_PRIVATE:
				return QINIU_IMAGES_PRIVATE;
			case BUCKET_IMAGES_OPEN:
				return QINIU_IMAGES_OPEN;
			case BUCKET_ARCHIVES_PRIVATE:
				return QINIU_ARCHIVES_PRIVATE;
			case BUCKET_ARCHIVES_OPEN:
				return QINIU_ARCHIVES_OPEN;
			case BUCKET_QRTUAN:
				return QINIU_QRTUANT;
			case BUCKET_VSTARTEST:
				return QINIU_VSTARTEST;
			default:
				throw new VSException("空间类型（"+bucketType+"）不能识别");
			}
		}else {
			throw new VSException("云服务类型（"+ossName+"）不能识别");
		}
	}
}
